<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>ode_discrete</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : February 1998</div>
    <p>
      <b>ode_discrete</b> -  ordinary differential equation solver, discrete time simulation</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>y=ode("discrete",y0,k0,kvect,f)  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>y0</b>
        </tt>: real vector or matrix (initial conditions).</li>
      <li>
        <tt>
          <b>t0</b>
        </tt>: real scalar (initial time).</li>
      <li>
        <tt>
          <b>f</b>
        </tt>: external i.e. function or character string or list.</li>
      <li>
        <tt>
          <b>k0</b>
        </tt>: integer (initial time).</li>
      <li>
        <tt>
          <b>kvect</b>
        </tt>: integer vector.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    With this syntax (first argument equal to <tt>
        <b>"discrete"</b>
      </tt>)
    <tt>
        <b>ode</b>
      </tt> computes recursively <tt>
        <b>y(k+1)=f(k,y(k))</b>
      </tt>
    from an initial state
    <tt>
        <b>y(k0)</b>
      </tt> and returns <tt>
        <b>y(k)</b>
      </tt> for <tt>
        <b>k</b>
      </tt> in <tt>
        <b>kvect</b>
      </tt>.
    <tt>
        <b>kvect(1)</b>
      </tt> must be greater than or equal to <tt>
        <b>k0</b>
      </tt>.</p>
    <p>
    Other arguments and other options are the same as for <tt>
        <b>ode</b>
      </tt>, see the
    ode help.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

y1=[1;2;3]; deff("yp=a_function(k,y)","yp=A*y+B*u(k)")
A=diag([0.2,0.5,0.9]); B=[1;1;1];u=1:10;n=5;
y=ode("discrete",y1,1,1:n,a_function);
y(:,2)-(A*y1+B*u(1))
// Now y evaluates  at [y3,y5,y7,y9]
y=ode("discrete",y1,1,3:2:9,a_function)
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="ode.htm">
        <tt>
          <b>ode</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
